const validate = require("../utils/validate");
const Joi = require("joi");
const StringRequired = Joi.string().trim().required();

const tableQuery = {
  fileds: Joi.optional(),
  sort: Joi.optional(),
  numeric: Joi.optional(),
  page: Joi.optional(),
  pageSize: Joi.optional(),
};

exports.loginSchema = validate({
  body: {
    email: StringRequired.messages({
      "string.empty": `邮箱不能为空`,
    }),
    password: StringRequired.messages({
      "string.empty": `密码不能为空`,
    }),
  },
});

exports.jobsSchema = validate({
  query: {
    ...tableQuery,
    company: Joi.optional(),
    jobType: Joi.string()
      .allow("ALL", "FULL_TIME", "PART_TIME", "REMOTE", "INTERNSHIP")
      .optional(),
    status: Joi.string()
      .allow("ALL", "INTERVIEW", "DECLINED", "PENDING")
      .optional(),
  },
});
